// import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
// import axios from 'axios'
// import ElementUI from 'element-ui';
// import 'element-ui/lib/theme-chalk/index.css';
import { imageUrl, videoUrl, mainUrl, resourceUrl } from "@/public/uri.js"
Vue.use(ELEMENT);

axios.defaults.withCredentials = true;
Vue.prototype.$axios = axios;



// music  --star

Vue.filter('toStringMusicTime', (data) => {
  let minute = data / 1000 / 60 | 0;
  let second = data / 1000 % 60 | 0;
  if (second.toString().length === 1) {
    second = "0" + second
  }
  return `${minute}:${second}`
})


Vue.filter('setWNum', (num) => {
  num = (num / 10000).toFixed(2);
  if (num[num.length - 1] === "0") {
    let newNum = Number(num).toFixed(1);
    if (newNum[newNum.length - 1] === "0") {
      return Number(newNum).toFixed(0) + "万";
    } else {
      return newNum;
    }
  } else {
    return num + "万";
  }

})

//music  --end



Vue.filter('setDate', (date) => {
  date = new Date(date)
  return date.toLocaleString('chinese', { hour12: false })
  // return `${date.getFullYear()}.${date.getMonth() +
  //   1}.${date.getDate()}`;
});

Vue.filter('squareUrls', url => {
  if (url) {
    return `${imageUrl}/${url}`
  } else {
    return "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png"
  }
})

Vue.filter('squareUrlsMain', url => {
  if (url) {
    return `${mainUrl}/${url}`
  } else {
    return "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png"
  }
})

Vue.filter('squareUrlsResource', url => {
  if (url) {
    return `${resourceUrl}/${url}`
  } else {
    return "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png"
  }
})


Vue.filter('upload', url => {
  if (url) {
    return `${resourceUrl}/${url}`
  } else {
    return
  }
})



Vue.filter('setStateStyle', (state) => {
  if (state) {
    return "公开"
  } else {
    return "私密"
  }
});


Vue.filter('setImageUrl', (image) => {
  return `${imageUrl}/${image}`;
});

Vue.filter('setVideoUrl', (video) => {
  return `${videoUrl}/${video}`;
});

import loading from '@/components/loading'
Vue.component('loading', loading)

import bei from '@/components/bei/index.vue'
Vue.component('bei', bei)


import footnote from "@/components/footnote";

Vue.component('footnote', footnote)

import nodata from "@/components/nodata"
Vue.component('nodata', nodata)
Vue.config.productionTip = false


new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
